package com.qianyu.versioncontrolapi.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qianyu.versioncontrolapi.service.OptionLogService;
import com.qianyu.versioncontrolcore.entity.base.PageDTO;
import com.qianyu.versioncontrolcore.entity.bean.OptionLog;
import com.qianyu.versioncontrolapi.mapper.OptionLogMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;


@Service
@RequiredArgsConstructor
public class OptionLogServiceImpl extends ServiceImpl<OptionLogMapper, OptionLog> implements OptionLogService {

    @Override
    public void saveLog(OptionLog log) {
        save(log);
    }

    @Override
    public Page<OptionLog> pageList(PageDTO dto) {
        Page<OptionLog> page = new Page<>(dto.getPageNum(),dto.getPageSize());
        return (Page<OptionLog>) baseMapper.selectPage(page, Wrappers.<OptionLog>lambdaQuery().orderByDesc(OptionLog::getCreateTime));
    }
}
